﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using AssessmentTool.PresentationLogic;
using System.Windows.Media.Imaging;

namespace AssessmentTool.Controls
{
    public partial class MenuBottons : UserControl
    {

        public String First
        {
            get { return (String)GetValue(FirstProperty); }
            set { SetValue(FirstProperty, value); }
        }
        public static readonly DependencyProperty FirstProperty =
      DependencyProperty.Register("First", typeof(String), typeof(MenuBottons), new PropertyMetadata("", firstChangedCallback));

        private static void firstChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MenuBottons mb=(MenuBottons)d;
            if (((String)e.NewValue).CompareTo("YES") == 0)
            {
                mb.LayoutRoot.BorderThickness = new Thickness(0, 0, 0, 0);
            }
            else 
            {
                mb.LayoutRoot.BorderThickness = new Thickness(1, 0, 0, 0);
            }
        }


        public string TextIcon
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }
          public static readonly DependencyProperty TextProperty =
        DependencyProperty.Register("TextIcon", typeof(string), typeof(MenuBottons), new PropertyMetadata("", propertyChangedCallback));

          public string Image
        {
            get { return (string)GetValue(ImageProperty); }
            set { SetValue(ImageProperty, value); }
        }
        
        public static readonly DependencyProperty ImageProperty =
        DependencyProperty.Register("Image", typeof(string), typeof(MenuBottons), new PropertyMetadata("", propertyChangedCallback));

        public string EventName
        {
            get { return (string)GetValue(EventNameProperty); }
            set { SetValue(EventNameProperty, value); }
        }
        public static readonly DependencyProperty EventNameProperty =
      DependencyProperty.Register("EventName", typeof(string), typeof(MenuBottons), new PropertyMetadata("", propertyChangedCallback));

        
        public MenuBottons()
        {
            InitializeComponent();
            
        }


       
        
        private static void propertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //empty
        }
        private void UserControl_MouseEnter(object sender, MouseEventArgs e)
        {
            VisualStateManager.GoToState(this, "MouseOver", true);
        }

        private void UserControl_MouseLeave(object sender, MouseEventArgs e)
        {
            VisualStateManager.GoToState(this, "Normal", true);
        }

        private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            VisualStateManager.GoToState(this, "Pressed", true);
        }

        private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            EventDispatcher.getInstance().dispatch("BUSY", null);
            VisualStateManager.GoToState(this, "Normal", true);
            EventDispatcher.getInstance().dispatch(EventName, e);
            
        }
    }
}
